﻿using UnityEngine;
using System.Collections;

public class HealthController : MonoBehaviour {
	
	public static HealthController Instance;
	public UISlider slider;
	private float hp = 100;
		

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void Awake()
	{
		Instance = this;
		slider = GetComponent<UISlider>();
	}
	
	public void Damage(float dmgValue)
	{
		hp = Mathf.Clamp(hp - dmgValue, 0, 100);
		slider.value = hp * 0.01f;
		if( hp < 0)
		{
			Application.LoadLevel(Application.loadedLevel);
		}
		
	}
	
	
}
